from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `tb_monitor_log` ADD `error_log` LONGTEXT COMMENT '错误日志';
        ALTER TABLE `tb_monitor_log` ADD `request_id` VARCHAR(20) NOT NULL COMMENT '请求Id';
        ALTER TABLE `tb_system_dept` MODIFY COLUMN `path` VARCHAR(20) NOT NULL COMMENT '路径';
        ALTER TABLE `tb_system_dept` MODIFY COLUMN `name` VARCHAR(20) NOT NULL COMMENT '部门名称';
        ALTER TABLE `tb_system_dept` ALTER COLUMN `active` SET DEFAULT 0;
        ALTER TABLE `tb_system_role` ALTER COLUMN `active` SET DEFAULT 0;
        ALTER TABLE `tb_system_user` ALTER COLUMN `active` SET DEFAULT 0;"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `tb_monitor_log` DROP COLUMN `error_log`;
        ALTER TABLE `tb_monitor_log` DROP COLUMN `request_id`;
        ALTER TABLE `tb_system_dept` MODIFY COLUMN `path` VARCHAR(20) COMMENT '路径';
        ALTER TABLE `tb_system_dept` MODIFY COLUMN `name` VARCHAR(20) COMMENT '部门名称';
        ALTER TABLE `tb_system_dept` ALTER COLUMN `active` SET DEFAULT 1;
        ALTER TABLE `tb_system_role` ALTER COLUMN `active` SET DEFAULT 1;
        ALTER TABLE `tb_system_user` ALTER COLUMN `active` SET DEFAULT 1;"""
